package com.ftg.learn.chapter08.homework01.homework06;

/**
 * 测试
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/7/24 20:43
 */

public class Test1 {

    public static void main(String[] args) {
        GirlFriend[] girl=new GirlFriend[4];

    GirlFriend girlFriend=new GirlFriend("li",19,"女","睡觉");
    GirlFriend girlFriend1=new GirlFriend("cc",24,"女","唱歌");
    GirlFriend girlFriend2=new GirlFriend("xx",22,"女","学习");
    GirlFriend girlFriend3=new GirlFriend("gg",27,"女","玩");

    girl[0]=girlFriend;
    girl[1]=girlFriend1;
    girl[2]=girlFriend2;
    girl[3]=girlFriend3;

        int sum=0;
        int num=0;
        int avg=0;
        int lnum=0;
        for (int i = 0; i < girl.length; i++) {
            sum+=girl[i].getAge();
            num++;
        }
        avg=sum/num;
        System.out.println("平均年龄为："+avg);

        for (int i = 0; i < girl.length; i++) {
            if(girl[i].getAge()<avg){
                lnum++;
                girl[i].disp();
            }
        }
        System.out.println("有"+lnum+"个比平均值"+avg+"低的");

    }

}
